#include <iostream>
using namespace std;

int main() {

	int t;
	cin>>t;
	while(t--){
		int h,a,H,A;
		cin>>h>>a>>H>>A;
		if(H==0 || A==0){
			cout<<-1<<endl;
		}
		else if(a==0){
			cout<<0<<endl;
		}
		else{
			int nCnt=(h-1)/A;
			int nSingle=H/a+(H%a==0?0:1)-1;
			if(nSingle==0){
				cout<<-1<<endl;
			}
			else{
				cout<<(nCnt/nSingle)<<endl;
			}
			
		}
	}
}
